import { defineConfig } from 'vite';
// @ts-ignore
import vue from '@vitejs/plugin-vue';
//import styleImport from 'vite-plugin-style-import';
import { resolve } from 'path';
import { api } from "./src/utils";

// @ts-ignore
export default defineConfig({
  server: {
    proxy: {
      '/api': {
        target: api,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '/api')
      }
    }
  },
  build: {
    target: ['es2015']
  },
  plugins: [
    vue(),
    /*styleImport({
      libs: [{
        libraryName: 'ant-design-vue',
        esModule: true,
        resolveStyle: (name) => {
          return `ant-design-vue/es/${name}/style/css`;
        },
      }]
    })*/
  ],
  resolve: {
    /*alias: [
      {
        find: /^\/@\//,
        replacement: pathResolve('src') + '/',
      }
    ]*/
    alias:{
      '@': resolve(__dirname, './src')
    }

  },
  css: {
    preprocessorOptions: {
      less: {
        modifyVars: {
          hack: `true; @import (reference) "${resolve('src/design/config.less')}";`,
        },
        javascriptEnabled: true,
      }
    }
  }
})

